#!/bin/bash
if [ $# -ne 2 ] ; then
echo "Usage: $0 "
exit
fi

tmpfile=`mktemp`
datetime=`date -d '1 month ago' +%F`

touch --date $datetime $tmpfile

echo "正在备份目录$1的文件..."
find $1  tar -puvf $2 {} \;

echo "删除超过一个月的文件..."
find $1 ! -newer $tmpfile -exec rm -frv {}
